package bancosys.tec.security.impl.permission.parser.impl;

import java.util.HashSet;
import java.util.Set;

import bancosys.tec.security.authorization.ActionPermission;
import bancosys.tec.security.impl.permission.parser.PermissionParser;
import bancosys.tec.security.web.ActionMapping;

/**
 * {@link PermissionParser} para {@link ActionPermission}
 * 
 * @author takeshi
 */
public class ActionPermissionParser implements PermissionParser {

    private final Set<String> actions = new HashSet<String>(ActionMapping.getInstance().getMapping().values());

    /**
     * {@inheritDoc}
     * 
     * @see jmine.tec.security.sg.permission.parser.PermissionParser#parse(java.lang.String)
     */
    public ActionPermission parse(String permission) {
        if (this.actions.contains(permission)) {
            return new ActionPermission(permission);
        }
        return null;
    }

}
